<?php

//News model class

class Content_model extends MY_Model {
    var $userId;
    function Content_model(){
        //$this->load->Model('');
    }
    
    function getTheContent($userId,$page=false,$limit=false){
          $sqlData = 'SELECT * FROM((
                        SELECT "News" AS `type_of_content` , id, article_heading, posted_date,"" AS additional
                        FROM news
                        WHERE id_user_tiab = "'.$userId.'")
                    UNION (
                        SELECT "Crime Report" AS `type_of_content` , T1.id, T2.name, date_created,"" AS additional
                        FROM crime_report T1, crime_type T2
                        WHERE T1.crime_type = T2.id
                        AND T1.id_user_tiab = "'.$userId.'")
                    UNION (
                        SELECT "Alerts" AS `type_of_content` , id, short_alert, created_date,id_network AS additional
                        FROM alerts
                        WHERE id_user = "'.$userId.'"
                    )
                    UNION (
                        SELECT "Alerts Comment" AS `type_of_content` , TA1.id,
                        TA1.COMMENT , TA1.created_date,id_network AS additional
                        FROM alerts_comment TA1, Alerts TA2
                        WHERE TA1.alerts_id = TA2.id AND user_tiab_id = "'.$userId.'")
                    UNION (
                        SELECT "News Comment" AS `type_of_content` , id, comment_txt, created_date,tiab_news_id AS additional
                        FROM news_comments
                        WHERE id_user_tiab = "'.$userId.'" )) TX ORDER BY posted_date DESC';
        return $this->getListBySQL($sqlData,$page,$limit);
    }
	
}
?>